<!DOCTYPE html>
<html><head>
	    <meta charset="utf-8">
    <title>ThinkPHP5.0</title>

    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__STATIC__/admin/style/bootstrap.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/font-awesome.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/weather-icons.css" rel="stylesheet">
    <script src="__STATIC__/admin/style/jquery_002.js"></script>
    <script src="__STATIC__/admin/plus/layer/layer.js"></script>

    <!--Beyond styles-->
    <link id="beyond-link" href="__STATIC__/admin/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__STATIC__/admin/style/demo.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/typicons.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/animate.css" rel="stylesheet">
    
</head>
<body>
	<!-- 头部 -->
    {include file="common/head"}
	<!-- /头部 -->
	
	<div class="main-container container-fluid">
		<div class="page-container">
            <!-- Page Sidebar -->
            {include file="common/left"}
            <!-- /Page Sidebar -->
            <!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                                        <li>
                        <a href="{:url('index/index')}">系统</a>
                    </li>
                                        <li class="active">字段列表</li>
                                        </ul>
                </div>
                <!-- /Page Breadcrumb -->

                <!-- Page Body -->
                <div class="page-body">
                    
<button type="button" tooltip="添加字段" class="btn btn-sm btn-azure btn-addon" onClick="javascript:window.location.href = '{:url('add')}'"> <i class="fa fa-plus"></i> Add
</button>
<div class="row">
    <div class="col-lg-12 col-sm-12 col-xs-12">
        <div class="widget">
            <div class="widget-body">
                <div class="flip-scroll">
                    <table class="table table-bordered table-hover">
                        <thead class="">
                            <tr>
                                <th class="text-center" width="6%">ID</th>
                                <th class="text-center">中文名称</th>
                                <th class="text-center">英文名称</th>
                                <th class="text-center">字段类型</th>
                                <th class="text-center">所属类型</th>
                                <th class="text-center" width="15%">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        {volist name="fieldRes" id="field"}
                         <tr>
                            <td align="center">{$field.id}</td>
                            <td align="center">{$field.field_cname}</td>
                            <td align="center">{$field.field_ename}</td>
                            <td align="center">
                                {switch $field.field_type}
                                {case 1}单行文本 {/case}
                                {case 2}单选按钮 {/case}
                                {case 3}复选框 {/case}
                                {case 4}下拉菜单 {/case}
                                {case 5}文本域 {/case}
                                {case 6}附件{/case}
                                {case 7}浮点 {/case}
                                {case 8}整形 {/case}
                                {case 9}长文本 {/case}
                                {/switch}
                            </td>
                             <td align="center">{$field.model_name}</td>

                             <td align="center">
                                    <a href="{:url('ModelFields/edit',array('id'=>$field['id']))}" class="btn btn-primary btn-sm shiny">
                                        <i class="fa fa-edit"></i> 编辑
                                    </a>
                                    <a href="#" id="{$field.id}" onClick="ajaxDel(this);" class="btn btn-danger btn-sm shiny">
                                        <i class="fa fa-trash-o"></i> 删除
                                    </a>
                                </td>
                          </tr>
                        {/volist}
                        </tbody>
                    </table>
                    <div style="padding-top: 10px; text-align: right;">
                        {$fieldRes->render()}
                    </div>
                </div>
                <div>
                </div>
            </div>
        </div>
    </div>
</div>

                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->
		</div>	
	</div>

	    <!--Basic Scripts-->

    <script src="__STATIC__/admin/style/bootstrap.js"></script>

    <!--Beyond Scripts-->
    <script src="__STATIC__/admin/style/beyond.js"></script>
    <script type="text/javascript">
        //ajax删除字段
        function ajaxDel(o) {
            layer.confirm('确定要删除该字段吗?', {icon: 3, title: '提示'}, function (index) {
                var id = $(o).attr("id");
//                var table_name=$(o).attr("table_name");
                $.ajax({
                    type: "post",
                    dataType: "json",
                    data: {id: id},
                    url: "{:url('modelFields/ajaxDel')}",
                    success: function (data) {
                        if (data == 1) {
                            layer.msg('删除字段成功!', {icon: 1})
                            window.location.href = "{:url('index')}"
                        } else {
                            layer.msg('删除字段失败!', {icon: 2})
                        }
                    }
                });
                layer.close(index);
            });
        }
    </script>


</body></html>